package servlets;

import beans2.Patient;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import service2.SignService;

import java.io.IOException;

public class AddPatient extends HttpServlet {//添加患者
    //添加YY_sign
    //添加YY_indent
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        SignService signService=new SignService();
        Patient patient=new Patient();
        patient.setOrder(Integer.parseInt(req.getParameter("number")));
        patient.setAccount(req.getParameter("id"));
        patient.setName(req.getParameter("name"));
        System.out.println("AddPatient began");
        if(!signService.AddPatient(patient,Integer.parseInt((String)req.getSession().getAttribute("schid")))){
            System.out.println("AddPatient  ERROR");
        }else{
            System.out.println("AddPatient YES");
        }
        resp.sendRedirect("Callpatient.jsp");
        System.out.println("AddPatient over");
    }
}
